//
//  LoginGateway.swift
//  CleanArchitecture
//
//  Created by siri on 2024/11/7.
//  Copyright © 2024 Tuan Truong. All rights reserved.
//




import Combine
import Foundation
import Factory
import APIService

protocol LoginGatewayProtocol {
    func login(username: String, password: String)->  AnyPublisher<Res<TokenOutVO>,Error>
}

struct LoginGateway: LoginGatewayProtocol {
 
    // 登录请求接口
    func login(username: String, password: String) ->  AnyPublisher<Res<TokenOutVO>, Error> {
        APIServices.default
            .request(LoginEndpoint.login(username: username, password: password) )
            .data(type: Res<TokenOutVO>.self)
            .map {
                $0
            }.eraseToAnyPublisher()
    }
}

extension Container {
    var loginGateway: Factory<LoginGatewayProtocol> {
        Factory(self) {LoginGateway() }
//            .onPreview {
//                PreviewMyMeetingGateway()
//            }
    }
}
